from datetime import datetime, timedelta

class TimeCalculator:
    @staticmethod
    def calculate_time_difference(start_time, end_time):
        start_datetime = datetime.strptime(start_time, "%Y%m%d-%H%M%S")
        end_datetime = datetime.strptime(end_time, "%Y%m%d-%H%M%S")
        time_difference = (end_datetime - start_datetime).total_seconds()
        return time_difference

    @staticmethod
    def convert_to_minutes(time_difference):
        minutes = time_difference / 60
        return minutes

    @staticmethod
    def convert_to_hours(time_difference):
        hours = time_difference / 3600
        return hours

    @staticmethod
    def calculate_end_time(start_time, time_difference):
        start_datetime = datetime.strptime(start_time, "%Y%m%d-%H%M%S")
        end_datetime = start_datetime + timedelta(seconds=time_difference)
        end_time = end_datetime.strftime("%Y%m%d-%H%M%S")
        return end_time

    @staticmethod
    def calculate_start_time(end_time, time_difference):
        end_datetime = datetime.strptime(end_time, "%Y%m%d-%H%M%S")
        start_datetime = end_datetime - timedelta(seconds=time_difference)
        start_time = start_datetime.strftime("%Y%m%d-%H%M%S")
        return start_time

# 示例用法
start_time = "20240109-113540"
end_time = "20240110-082849"
time_difference = TimeCalculator.calculate_time_difference(start_time, end_time)
minutes = TimeCalculator.convert_to_minutes(time_difference)
hours = TimeCalculator.convert_to_hours(time_difference)
print("时间差值（秒）：", time_difference)
print("时间差值（分钟）：", minutes)
print("时间差值（小时）：", hours)

# start_time = "20231227-152150"
# time_difference = 450
# end_time = TimeCalculator.calculate_end_time(start_time, time_difference)
# print("结束时间：", end_time)

# end_time = "20231227-153000"
# time_difference = 450
# start_time = TimeCalculator.calculate_start_time(end_time, time_difference)
# print("起始时间：", start_time)
